#!/usr/bin/env python2.3

import time
import os.path
from activist.Config import Config
from twisted.internet import reactor

if not os.path.isdir(os.path.join(Config.base,'data/commands.log')):
    os.system( 'mkdir %s'%os.path.join(Config.base,'data/commands.log') )

from activist.DataStore import DataStore
from activist.Text import Text
from activist.Article import Article
from activist.CommandProcessor import CommandProcessor

import sys

if len(sys.argv) != 3:
    print "usage:",sys.argv[0],"<article-id> <filename>"
    sys.exit(-1)

CommandProcessor.loadAndProcess()
article = DataStore[sys.argv[1]]

print "ARTICLE:",article
if not article:
    sys.exit(0)

data = open(sys.argv[2],"r").read()
text = Text(data)
article.edit(text)

print "created text with id:",text.id()
print "...article has id:",article.id()

